import 'package:json_annotation/json_annotation.dart';

import '../common/utils.dart';

@JsonSerializable()
class Tts extends Object {
  @JsonKey(name: 'autoplay')
  int autoplay;

  Tts(
    this.autoplay,
  );

  factory Tts.fromJson(Map<String, dynamic> srcJson) => _$TtsFromJson(srcJson);
}

Tts _$TtsFromJson(Map<String, dynamic> json) => Tts(
      toInt(json['autoplay']),
    );

Map<String, dynamic> _$TtsToJson(Tts instance) => <String, dynamic>{
      'autoplay': instance.autoplay,
    };

@JsonSerializable()
class Bgm extends Object {
  @JsonKey(name: 'volume')
  double volume;

  @JsonKey(name: 'src')
  String? src;

  @JsonKey(name: 'loop')
  int loop;

  @JsonKey(name: 'autoplay')
  int autoplay;

  Bgm(
    this.volume,
    this.src,
    this.loop,
    this.autoplay,
  );

  factory Bgm.fromJson(Map<String, dynamic> srcJson) => _$BgmFromJson(srcJson);
}

Bgm _$BgmFromJson(Map<String, dynamic> json) => Bgm(
      toDouble(json['volume']),
      json['src'] as String?,
      toInt(json['loop']),
      toInt(json['autoplay']),
    );

Map<String, dynamic> _$BgmToJson(Bgm instance) => <String, dynamic>{
      'volume': instance.volume,
      'src': instance.src,
      'loop': instance.loop,
      'autoplay': instance.autoplay,
    };

@JsonSerializable()
class Chat extends Object {
  @JsonKey(name: 'src')
  String? src;

  @JsonKey(name: 'leave')
  String? leave;

  @JsonKey(name: 'action')
  String? action;

  @JsonKey(name: 'enter')
  String? enter;

  @JsonKey(name: 'type')
  String? type;

  Chat(this.src, this.leave, this.action, this.enter, this.type);

  factory Chat.fromJson(Map<String, dynamic> srcJson) => _$ChatFromJson(srcJson);
}

Chat _$ChatFromJson(Map<String, dynamic> json) => Chat(
      json['src'] as String?,
      json['leave'] as String?,
      json['action'] as String?,
      json['enter'] as String?,
      json['type'] as String?,
    );

Map<String, dynamic> _$ChatToJson(Chat instance) => <String, dynamic>{
      'src': instance.src,
      'leave': instance.leave,
      'action': instance.action,
      'enter': instance.enter,
      'type': instance.type,
    };

@JsonSerializable()
class MessageItemModel extends Object {
  @JsonKey(name: 'val')
  String? val;

  @JsonKey(name: 'type')
  String? type;

  @JsonKey(name: 'group')
  String group;

  @JsonKey(name: 'inName')
  String? inName;

  @JsonKey(name: 'name')
  String? name;

  @JsonKey(name: 'sub')
  List<MessageItemModel>? sub;

  MessageItemModel(
    this.val,
    this.type,
    this.group,
    this.inName,
    this.name,
    this.sub,
  );

  factory MessageItemModel.fromJson(Map<String, dynamic> srcJson) => _$MessageItemModelFromJson(srcJson);

  Map<String, dynamic> toJson() => _$MessageItemModelToJson(this);
}

MessageItemModel _$MessageItemModelFromJson(Map<String, dynamic> json) => MessageItemModel(
      toString(json['val']),
      json['type'] as String?,
      toString(json['group']),
      json['inName'] as String?,
      json['name'] as String?,
      (json['sub'] as List<dynamic>?)?.map((e) => MessageItemModel.fromJson(e as Map<String, dynamic>)).toList(),
    );

Map<String, dynamic> _$MessageItemModelToJson(MessageItemModel instance) => <String, dynamic>{
      'val': instance.val,
      'type': instance.type,
      'group': instance.group,
      'inName': instance.inName,
      'sub': instance.sub,
    };

@JsonSerializable()
class PipeAlbumMessageModel extends Object {
  @JsonKey(name: 'val')
  String val;

  @JsonKey(name: 'chainName')
  String? chainName;

  @JsonKey(name: 'split')
  int? split;

  @JsonKey(name: 'chainId')
  String? chainId;

  @JsonKey(name: 'name')
  String? name;

  @JsonKey(name: 'id')
  String? id;

  @JsonKey(name: 'type')
  String? type;

  @JsonKey(name: 'group')
  String? group;

  @JsonKey(name: 'sub')
  List<PipeAlbumMessageModel>? sub;

  @JsonKey(name: 'prop')
  Map<String, dynamic>? prop;

  PipeAlbumMessageModel(this.val, this.chainName, this.split, this.chainId, this.name, this.id, this.type, this.group, this.sub, this.prop);

  factory PipeAlbumMessageModel.fromJson(Map<String, dynamic> srcJson) => _$PipeAlbumMessageModelFromJson(srcJson);

  Map<String, dynamic> toJson() => _$PipeAlbumMessageModelToJson(this);
}

PipeAlbumMessageModel _$PipeAlbumMessageModelFromJson(Map<String, dynamic> json) => PipeAlbumMessageModel(
      toString(json['val']),
      json['chainName'] as String?,
      (json['split'] as num?)?.toInt(),
      json['chainId'] as String?,
      json['name'] as String?,
      json['id'] as String?,
      json['type'] as String?,
      json['group'] as String?,
      (json['sub'] as List<dynamic>?)?.map((e) => PipeAlbumMessageModel.fromJson(e as Map<String, dynamic>)).toList(),
      json['prop'] as Map<String, dynamic>?
    );

Map<String, dynamic> _$PipeAlbumMessageModelToJson(PipeAlbumMessageModel instance) => <String, dynamic>{
      'val': instance.val,
      'chainName': instance.chainName,
      'split': instance.split,
      'chainId': instance.chainId,
      'name': instance.name,
      'id': instance.id,
      'type': instance.type,
      'group': instance.group,
      'sub': instance.sub,
    };

@JsonSerializable()
class MessageShortcutModel extends Object {
  @JsonKey(name: 'val')
  String val;

  @JsonKey(name: 'sub')
  List<ShortcutItemModel> sub;

  @JsonKey(name: 'type')
  String type;

  @JsonKey(name: 'inName')
  String inName;

  MessageShortcutModel(
    this.val,
    this.sub,
    this.type,
    this.inName,
  );

  factory MessageShortcutModel.fromJson(Map<String, dynamic> srcJson) => _$MessageShortcutModelFromJson(srcJson);

  Map<String, dynamic> toJson() => _$MessageShortcutModelToJson(this);
}

@JsonSerializable()
class ShortcutItemModel extends Object {
  @JsonKey(name: 'val')
  String? val;

  @JsonKey(name: 'type')
  String? type;

  @JsonKey(name: 'inName')
  String inName;

  ShortcutItemModel(
    this.val,
    this.type,
    this.inName,
  );

  factory ShortcutItemModel.fromJson(Map<String, dynamic> srcJson) => _$ShortcutItemModelFromJson(srcJson);

  Map<String, dynamic> toJson() => _$ShortcutItemModelToJson(this);
}

MessageShortcutModel _$MessageShortcutModelFromJson(Map<String, dynamic> json) => MessageShortcutModel(
      json['val'] as String,
      (json['sub'] as List<dynamic>).map((e) => ShortcutItemModel.fromJson(e as Map<String, dynamic>)).toList(),
      json['type'] as String,
      json['inName'] as String,
    );

Map<String, dynamic> _$MessageShortcutModelToJson(MessageShortcutModel instance) => <String, dynamic>{
      'val': instance.val,
      'sub': instance.sub,
      'type': instance.type,
      'inName': instance.inName,
    };

ShortcutItemModel _$ShortcutItemModelFromJson(Map<String, dynamic> json) => ShortcutItemModel(
      toString(json['val']),
      json['type'] as String?,
      json['inName'] as String,
    );

Map<String, dynamic> _$ShortcutItemModelToJson(ShortcutItemModel instance) => <String, dynamic>{
      'val': instance.val,
      'type': instance.type,
      'inName': instance.inName,
    };
